import request from "@/utils/http/request";

export interface TrademarkData {
  id?: number;
  tmName: string;
  logoUrl: string;
}

export type TrademarkListData = TrademarkData[];

export type TrademarkResData = {
  records: TrademarkListData;
  total: number;
  size: number;
  current: number;
  searchCount: boolean;
  pages: number;
};

export default {
  // 获取trademark分页数据
  // GET /admin/product/baseTrademark/{page}/{limit}
  reqTrademarkList(page: number, limit: number) {
    return request.get<any, TrademarkResData>(
      `/admin/product/baseTrademark/${page}/${limit}`
    );
  },

  // 一个接口完成添加和修改两个功能
  // POST /admin/product/baseTrademark/save
  // PUT /admin/product/baseTrademark/update
  addOrUpdateTrademark(trademark: TrademarkData) {
    if (!trademark.id) {
      //如果没有id证明是添加
      return request.post<any, null>(
        "/admin/product/baseTrademark/save",
        trademark
      );
    } else {
      //证明是修改
      return request.put<any, null>(
        "admin/product/baseTrademark/update",
        trademark
      );
    }
  },

  //删除trademark
  // Delete /admin/product/baseTrademark/remove/{id}
  removeTrademark(id: number) {
    return request.delete<any, null>(
      `/admin/product/baseTrademark/remove/${id}`
    );
  },
};
